-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use TestContainers for integration tests #798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
We can default the port to 6379 and override it using a system property with the correct port. In our configuration we can use standard PropertyPlaceholderConfigurer |
|
@rwinch I've added a commit that demonstrates the approach taken for integration testing of WAR based samples. This fails for reasons we've discussed the other day - I've opened testcontainers/testcontainers-java#369. |
|
I've updated the PR to pick up recent changes to The previous problem is still present though. There is however some feedback on testcontainers/testcontainers-java#369. |
|
Hi folks, @testcontainers is here :) I think I know why application server doesn't stop, I'll debug it on TestContainers' side. Meanwhile could you please provide more details on why are you trying to run testcontainers' containers as WAR-ed app? :) |
|
Hi @bsideup - thanks for taking a look at this! Regarding the motivation, our build currently depends on Redis service being available, which is used for integration testing of both our Redis-backed components and sample applications that use those components. We'd like to standardize and improve our integration tests using TestContainers, which would also make Docker the only external service our build depends on. Integration testing of Redis-backed components and sample apps that are Spring Boot based is straightforward using JUnit |
|
Thanks to @bsideup we have a workaround and are no longer blocked by testcontainers/testcontainers-java#369. I'll revisit the PR to address the integration testing of WAR based samples during this week. |
21b52d9 to
9d5483c
Compare
|
This should be ready now with the latest updates to the PR. Integration tests for Integration tests for
TestContainers also provide Oracle XE module, but this is problematic to include due to well know situation with availability of Oracle JDBC driver in public repos. There is also SQL Server module in the works, so we might include that once the release is out. Regarding the tricky part of this PR, the integration testing of WAR based samples using Gretty, I've opted to introduce a separate Redis configuration which is activated with Let me know what you think @rwinch. |
| ConfigurableApplicationContext configurableApplicationContext) { | ||
| TestPropertyValues | ||
| .of("spring.redis.host=" + redisContainer.getContainerIpAddress(), | ||
| "spring.redis.port=" + redisContainer.getMappedPort(6379)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also use getFirstMappedPort() since 1.4 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip!
|
Can you please update the README and guides? |
Done. I've added a reference to Docker as an alternative to Redis installation. |
|
Thanks for the PR! This is now merged |
This resolves #795.
Note: this is work in progress since WAR samples are still looking atlocalhost:6379.Regarding integration tests, I've added JDBC tests for PostgreSQL, MySQL and MariaDB. We should still decide which exact versions we want to test against, especially with MySQL/MariaDB. The same applies to Redis.
As far as those WAR samples are concerned, @rwinch do you have some idea how to handle this having in mind current Tomcat based integration tests?